package uk.co.hephistocles.blobGame;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Matrix4;

public class Drawer {
	private static ArrayList<Sprite> spriteList = new ArrayList<Sprite>();
	private static SpriteBatch batch = new SpriteBatch();
	
	public static void sketch(Sprite sprite) {
		spriteList.add(sprite);
	}
	public static void draw(float offX, float offY, float theta) {
		Matrix4 mat = 	new Matrix4().setToTranslation(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2,0).mul(
						new Matrix4().setFromEulerAngles(0,0,theta)).mul(
						new Matrix4().setToTranslation(-offX,-offY,0));
		batch.setTransformMatrix(mat);
		batch.begin();
		Sprite sprite;
		for (int i=0; i<spriteList.size(); i++) {
			sprite = spriteList.get(i);
			sprite.draw(batch);
		}
		batch.end();
		spriteList.clear();
	}
	public static void draw(float offX, float offY) {
		Matrix4 mat = 	new Matrix4().setToTranslation(Gdx.graphics.getWidth()/2-offX, Gdx.graphics.getHeight()/2-offY,0);
				
		batch.setTransformMatrix(mat);
		batch.begin();
		for (int i=0; i<spriteList.size(); i++) {
			spriteList.get(i).draw(batch);
		}
		batch.end();
		spriteList.clear();
	}
	public static void dispose() {
		batch.dispose();
		spriteList.clear();
	}
}
